#ifndef CSUGL_TIME_H
#define CSUGL_TIME_H

#include <chrono>
#include <string>
namespace csugl {

    // time
    template <typename T>
    struct Time { };

    // low-precision time, use glfwTime
    template <>
    struct Time<float> {
        static void init();
        static void update();

        static float currentTime();
        inline static float deltaTime() { return _deltaTime; }

    private:
        static float _currentTime;
        static float _deltaTime;
    };

    // low-precision time, use glfwTime
    using LowpTime = Time<float>;

    // high-precision time, use std::chrono
    template <>
    struct Time<double> {
        static void init();
        static void update();

        static double currentTime();
        inline static double deltaTime() { 
            // TODO highp delta time
            return _deltaTime; 
        }
        
    private:
        static std::chrono::steady_clock::time_point _startTime;
        static std::chrono::steady_clock::time_point _currentTime;
        static double _deltaTime;
    };

    // high-precision time, use std::chrono
    using HighpTime = Time<double>;

    template<typename T>
    struct Timer {};

    template<>
    struct Timer<float>
    {
        Timer(std::string const &name) : name(name)
        {
            start_time = std::chrono::steady_clock::now();
        }
        ~Timer();
        private:
        std::string name;
        std::chrono::steady_clock::time_point start_time;
        
    };

    using LogTimer = Timer<float>;

}

#endif
